﻿var FY0 = "┏━━━━━━━━━━━┓";
var FY1 = "┃       079MAX4       ┃";
var FY2 = "┃ 脚本仿制  　定制脚本 ┃";
var FY3 = "┃ 技术支持 　 游戏顾问 ┃";
var FY4 = "┃ ＷＺ添加　  地图制作 ┃";
var FY5 = "┃ 售登陆器    售下载器 ┃";
var FY6 = "┣━━━━━━━━━━━┫";
var FY7 = "┃唯一QQ: 782772124┃";
var FY8 = "┗━━━━━━━━━━━┛";
var FY9 = "怀旧岛单机交流群免费分享";
var 红色箭头 = "#fUI/UIWindow/Quest/icon6/7#";
var 正方箭头 = "#fUI/Basic/BtHide3/mouseOver/0#";
var status = 0;

//普通奖池
var itemList1 = [
	//物品id，几率，数字越大概率越大，数量


[1302227, 1, 1, 1],
[1312116, 1, 1, 1],
[1322162, 1, 1, 1],
[1332193, 1, 1, 1],
[1362067, 1, 1, 1],
[1372139, 1, 1, 1],
[1382168, 1, 1, 1],
[1402151, 1, 1, 1],
[1412104, 1, 1, 1],
[1422107, 1, 1, 1],
[1432138, 1, 1, 1],
[1452170, 1, 1, 1],
[1462159, 1, 1, 1],
[1472179, 1, 1, 1],
[1482140, 1, 1, 1],
[1492152, 1, 1, 1],
[1092074, 1, 1, 1],
[1092079, 1, 1, 1],
[1092084, 1, 1, 1],
[1302147, 1, 1, 1],
[1312062, 1, 1, 1],
[1322090, 1, 1, 1],
[1332120, 1, 1, 1],
[1332125, 1, 1, 1],
[1342033, 1, 1, 1],
[1372078, 1, 1, 1],
[1382099, 1, 1, 1],
[1402090, 1, 1, 1],
[1412062, 1, 1, 1],
[1422063, 1, 1, 1],
[1442111, 1, 1, 1],
[1452106, 1, 1, 1],
[1462091, 1, 1, 1],
[1472117, 1, 1, 1],
[1482079, 1, 1, 1],
[1492079, 1, 1, 1],
[1382226, 1, 1, 1],
[1452220, 1, 1, 1],
[1462208, 1, 1, 1],
[1332242, 1, 1, 1],
[1402214, 1, 1, 1],
[1472230, 1, 1, 1],
[1342087, 1, 1, 1],
[1482183, 1, 1, 1],
[1422156, 1, 1, 1],
[1492194, 1, 1, 1],
[1432182, 1, 1, 1],
[1382080, 1, 1, 1],
[1452085, 1, 1, 1],
[1462075, 1, 1, 1],
[1332099, 1, 1, 1],
[1402072, 1, 1, 1],
[1472100, 1, 1, 1],
[1412046, 1, 1, 1],
[1482046, 1, 1, 1],
[1492048, 1, 1, 1],
[1432061, 1, 1, 1],
[1302133, 1, 1, 1],
[1372058, 1, 1, 1]

];

var useNx = 10000000;
var sel0 = -1;
function start() {
	if(FY9 == "怀旧岛单机交流群免费分享" && FY7 == "┃唯一QQ: 782772124┃")
	{
		status = -1;
		action(1, 0, 0);
	}
	else
	{
		cm.sendOk("请勿更改版权信息,否则脚本将无法正常使用");
		cm.dispose();
	}
}

function action(mode, type, selection) {
    if (status == 0 && mode == 0) {
        cm.dispose();
        return;
    }
    if (mode == 1) {
        status++;
    } else {
        status--;
    }

    if (status == 0) {
    	var txt = "#d你可以从普通武器宝箱里随机获得以下物品#n#k\r\n";
		txt += "#d普通武器宝箱装备属性为: #b1-20随机全属性\r\n";
    	txt += "#d#L1##b"+红色箭头+" 打开箱子#l\r\n\r\n";
		txt += "\t#b"+正方箭头+" 奖品展示： \r\n";
		
		var txt2 = "";
		for (var i = 0; i < itemList1.length;  i++){
			txt2 += "#i"+itemList1[i][0]+":#";
		}
    	cm.sendSimple(txt + txt2);
    } else if (status == 1) {
		var jobid=cm.getPlayer().getJob();
		sel0 = selection;
		cm.sendGetNumber(""+正方箭头+"#d 请输入开启次数\r\n"
		+"#d每次开启箱子需要消耗1把#r#t4000435##d和1个#r普通武器宝箱\r\n#r联盟钥匙和普通武器宝箱#d可以通过怪物掉落/日常/活动等渠道获得",
		1, 1, 99999
		);
	} else if(status == 2) {
		if (!cm.checkNumSpace(0, selection)) {
			cm.sendOk("背包空间不足"+selection+"格");
			cm.dispose();
			return;
		}
    	switch (sel0) {
			case 1:
                if (!cm.haveItem(2430047,1*selection)) 
				{
					cm.sendOk("#v2430047#数量不足#r "+(1*selection)+" #k，无法抽奖");
					cm.dispose();
					return;
				} 
				else 
				{
					if(!cm.haveItem(2430047,1*selection))
					{
						cm.sendOk("#v2430047#数量不足#r "+(1*selection)+" #k，无法抽奖");
						cm.dispose();
						return;
					}
					else
					{
						cm.gainItem(2430047, -(1*selection));
						
					}
				}
				break;
			case 2:
                if (cm.getMeso() < (useNx*selection)) {
					cm.sendOk("金币不足"+(useNx*selection)+"，无法抽奖");
					cm.dispose();
					return;
				} else {
					cm.gainMeso(-useNx*selection);
				}
				break;
			default:
				cm.sendOk("脚本出错，请联系管理员");
				cm.dispose();
				return;
        }
		var txt = "恭喜你获得道具：\r\n";
		for (var i = 0; i < selection; i++) {
			var item;
			var ran = Math.floor(Math.random() * 100);
			var ran1 = null;
			ran1 = finalGift(itemList1);
			if(cm.getBossRankCount("屏蔽"+ran1[0]) > 0){
				cm.gainGachaponItem2(4001126, 1, "秘密箱子", ran1[3]);
			}
			else
			{
				var sjpp = Math.floor(Math.random()*20)+10;
				var suiji1 = Math.floor(Math.random()*20)+1;
				var suiji2 = Math.floor(Math.random()*20)+1;
				var suiji3 = Math.floor(Math.random()*20)+1;
				var suiji4 = Math.floor(Math.random()*20)+1;
				//var suijigg = Math.floor(Math.random()*25);
				//var suijigg2 = Math.floor(Math.random()*25);
				var suiji5 = Math.floor(Math.random()*200);
				cm.gainItem(ran1[0],suiji1,suiji2,suiji3,suiji4,suiji5,suiji5,0,0,0,0,0,0,0,0,0);
				cm.喇叭(1,"玩家"+cm.getPlayer().getName()+"从普通武器宝箱里开出了一件极品装备");
			}
			cm.gainItem(4000313, 1);
			//cm.gainItem(ran1[0] ,ran1[2])
			//cm.worldMessage("『抽奖捷报』：恭喜玩家."+ cm.getChar().getName() +"  获得["+ Packages.server.MapleItemInformationProvider.getInstance().getName(ran1[0]) +"]让我们热烈的祝福他/她吧！");
			txt += "#v" + ran1[0] + "#\r\n";
			//var result = cm.setBossRankCount("随机奖池抽奖");
			/*
			var ran2 = null;
			if (result%10 == 0) {//十连抽保底
				ran2 = finalGift(itemList1);
				cm.gainItem(ran2[0] ,ran2[2])
				txt += "额外道具：#v" + ran2[0] + "#\r\n";
			}
			*/
		}
		cm.dispose();
		return;
    }
}

function finalGift(lists) {
	var maxChance = 0;
	for (var i in lists) {
		if (lists[i][1] > maxChance) {
			maxChance = lists[i][1];
		}
	}
	var chance = Math.floor(Math.random() * maxChance);
	var finalitem = Array();
	for (var i = 0; i < lists.length; i++) {
		if (lists[i][1] >= chance) {
			finalitem.push(lists[i]);
		}
	}
	var ran1 = Math.floor(Math.random() * finalitem.length);
	return finalitem[ran1];
}